// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   JobtypeUI.java

package nc.ui.bd.b36;

import java.util.HashMap;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeModel;
import nc.bs.logging.Logger;
import nc.ui.ml.NCLangRes;
import nc.ui.pub.ButtonObject;
import nc.ui.pub.beans.UILabel;
import nc.ui.pub.beans.UITree;
import nc.ui.pub.bill.*;
import nc.ui.trade.bill.ICardController;
import nc.ui.trade.buffer.BillUIBuffer;
import nc.ui.trade.button.ButtonManager;
import nc.ui.trade.card.CardEventHandler;
import nc.ui.trade.pub.IVOTreeData;
import nc.ui.trade.treecard.BillTreeCardUI;
import nc.vo.bd.CorpVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.SuperVO;
import nc.vo.trade.pub.HYBillVO;

// Referenced classes of package nc.ui.bd.b36:
//			JobtypeEventHandler, JobtypeController, JobtypeTreeCardData, JobtypeTreeCellRenderer, 
//			JobtypeGetCheck

public class JobtypeUI extends BillTreeCardUI
{

	private static final long serialVersionUID = 0x5c6695f10cf7af50L;
	private IVOTreeData m_billtreedata;

	public JobtypeUI()
	{
	}

	public JobtypeUI(String pk_corp, String pk_billType, String pk_busitype, String operater, String billId)
	{
		super(pk_corp, pk_billType, pk_busitype, operater, billId);
	}

	public void afterEdit(BillEditEvent e)
	{
		try
		{
			((JobtypeEventHandler)getTreeCardEventHandler()).onUIChanged(e, true);
		}
		catch (Exception e1)
		{
			Logger.error(e1.getMessage(), e1);
			showErrorMessage(e1.getMessage());
		}
	}

	public void afterInit()
		throws Exception
	{
		super.afterInit();
		SuperVO nodes[] = getCreateTreeData().getTreeVO();
		if (nodes != null && nodes.length > 0)
		{
			if (getBufferData().isVOBufferEmpty())
			{
				for (int i = 0; i < nodes.length; i++)
				{
					SuperVO node = nodes[i];
					HYBillVO aVO = new HYBillVO();
					aVO.setParentVO(node);
					getBufferData().addVOToBuffer(aVO);
					getTreeToBuffer().put(node.getPrimaryKey(), (new StringBuilder()).append(i).append("").toString());
				}

			}
			resetTreeToBufferData();
		}
		DefaultMutableTreeNode node = (DefaultMutableTreeNode)getBillTree().getModel().getRoot();
		node.setUserObject(NCLangRes.getInstance().getStrByID("10081402", "UPP10081402-000001"));
	}

	public void clearCreateTreeData()
	{
		m_billtreedata = null;
	}

	protected ICardController createController()
	{
		return new JobtypeController();
	}

	protected CardEventHandler createEventHandler()
	{
		return new JobtypeEventHandler(this, getUIControl());
	}

	protected IVOTreeData createTableTreeData()
	{
		return null;
	}

	protected IVOTreeData createTreeData()
	{
		return new JobtypeTreeCardData(_getCorp().getPrimaryKey());
	}

	public IVOTreeData getCreateTreeData()
	{
		if (m_billtreedata == null)
			m_billtreedata = createTreeData();
		return m_billtreedata;
	}

	protected UITree getBillTree()
	{
		UITree tree = super.getBillTree();
		if (!(tree.getCellRenderer() instanceof JobtypeTreeCellRenderer))
			tree.setCellRenderer(new JobtypeTreeCellRenderer());
		return tree;
	}

	public String getRefBillType()
	{
		return null;
	}

	public Object getUserObject()
	{
		return new JobtypeGetCheck();
	}

	protected void initSelfData()
	{
		BillItem demoItem = getBillCardPanel().getHeadItem("codeRuleDemo");
		demoItem.getCaptionLabel().setText((new StringBuilder()).append(NCLangRes.getInstance().getStrByID("10081404", "UPP10081404-000045")).append(": ").toString());
		demoItem.getCaptionLabel().setEnabled(false);
		UILabel codeDemoInfo = new UILabel();
		codeDemoInfo.setText(NCLangRes.getInstance().getStrByID("10081402", "UPP10081402-000033"));
		demoItem.setComponent(codeDemoInfo);
		getBillCardPanel().setBillData(getBillCardPanel().getBillData());
	}

	public void updateButtons()
	{
		int nOperator = getBillOperate();
		if (nOperator == 4 || nOperator == 2)
			getButtonManager().getButton(8).setEnabled(true);
		super.updateButtons();
	}

	public void setDefaultData()
		throws Exception
	{
		getBillCardPanel().setHeadItem("pk_corp", _getCorp().getPrimaryKey());
		super.setDefaultData();
	}

	public void updateLineButton(ButtonObject bo)
		throws BusinessException
	{
		if (Integer.parseInt(bo.getTag()) == 10)
			updateButton(bo);
	}
}
